//
//  VerifyViewController.m
//  RainbowFM
//
//  Created by chenli on 14/12/10.
//  Copyright (c) 2014年 RB. All rights reserved.
//

#import "VerifyViewController.h"
#import "LoginModel.h"
#import "PwdViewController.h"

@interface VerifyViewController ()
@property (weak, nonatomic) IBOutlet UITextField *codeField;

@end

@implementation VerifyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/**
 *  重新发送
 *
 *  @param sender <#sender description#>
 */
- (IBAction)resendAction:(id)sender {
    [[LoginModel sharedModel] fetchSecurityCodeWithPhoneNum:_phoneNum result:^(BOOL success, NSString *msg) {
        if (success) {
            [SVProgressHUD showSuccessWithStatus:msg];
        }else{
            [SVProgressHUD showErrorWithStatus:msg];
        }
    }];
}

- (IBAction)nextAction:(id)sender {
    [[LoginModel sharedModel] verifyPhoneNumAndCode:_codeField.text phoneNum:_phoneNum result:^(BOOL success, NSString *code, NSString *msg) {
        if (success) {
            PwdViewController *pwdView = [self.storyboard instantiateViewControllerWithIdentifier:@"PwdViewController"];
            pwdView.smsCode = code;
            pwdView.phoneNum = _phoneNum;
            [self.navigationController pushViewController:pwdView animated:YES];
        }
        else
        {
            [SVProgressHUD showErrorWithStatus:msg];
        }
    }];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
